home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / BIN$.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  113 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   BIN$    .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22.  
  23. SHARED sMask$ : sMask$ = "##,###,###,### or "
  24.  
  25. COLOR 7, 0
  26. CLS
  27. ? "┌────────────────────────
  28. ? "│ fBIN$( Value&, Bytes? ) converts a decimal number into a binary
  29. ? "│                         expression that has been padded and formatted
  30. ? "│                         to the length you have requested.
  31. ? "│
  32. ? "│ fBINvalB?( B$ )         converts DASoft's binary strings or standard
  33. ? "│                         binary strings back into decimal numbers.
  34. ? "├──────────────────────────────────────────────────────────────────────┘
  35. ? "│ fBIN$ creates binary strings that allow for easy viewing.
  36. ? "│ They can only be used, again, as numbers by fBINvalL&.
  37. ? "│ These routines were used to enhance the printing of binary
  38. ? "│ expressions while programming. It really started out as a little
  39. ? "│ programming tool but seems to have grown up!
  40. ? "└────────────────────────────────────────────────────────────────────────┘
  41.  
  42. LOCATE 15,  1 : PRINT "DASoft:"
  43. LOCATE 16, 56 : PRINT "<HOME> & <END>  +-    1"
  44. LOCATE 17, 56 : PRINT "<UP>   & <DOWN> +-  100"
  45. LOCATE 18, 56 : PRINT "<PgUp> & <PgDn> +- 1000"
  46. LOCATE 19,  1 : PRINT "PowerBASIC:"
  47. LOCATE 25, 56 : PRINT "PRESS <ESC> TO END";
  48.  
  49.                                                     '┌──────────────────────
  50. B? =  95                                            '│ assign some values
  51. I% =  56                                            '│ to start with
  52. L& = 65536                                          '│
  53. DO                                                  '│
  54.   DisplayB B?                                       '│ display the results
  55.   DisplayI I%                                       '│
  56.   DisplayL L&                                       '│
  57.   WHILE INSTAT : G$ = INKEY$ : WEND                 '│ clear the keyboard
  58.   WHILE NOT INSTAT : WEND                           '│ wait for a key press
  59.   SELECT CASE INKEY$                                '│ evaluate the key press
  60.     CASE CHR$(27)      : EXIT LOOP                  '│ <ESC> end program
  61.     CASE CHR$(000,071) : B? = MIN(   255, B? + 1)   '│ <HOME> incr B?,    1
  62.     CASE CHR$(000,079) : B? = MAX(     0, B? - 1)   '│ <END>  decr B?,    1
  63.     CASE CHR$(000,072) : I% = MIN( 32767, I% + 100) '│ <UP>   incr I%,  100
  64.     CASE CHR$(000,080) : I% = MAX(-32767, I% - 100) '│ <DOWN> decr I%,  100
  65.     CASE CHR$(000,073) : INCR L&, 1000              '│ <PgUp> incr L&, 1000
  66.     CASE CHR$(000,081) : DECR L&, 1000              '│ <PgDn> decr L&, 1000
  67.   END SELECT                                        '│
  68. LOOP                                                '│
  69. '────────────────────────────────────────────────────┼──────────────────────
  70. CLS                                                 '│ end of program
  71. END                                                 '│
  72. '────────────────────────────────────────────────────┴──────────────────────
  73.  
  74. SUB DisplayB( BYVAL B? ) LOCAL PUBLIC
  75.   LOCAL B$
  76.  
  77.   LOCATE 16, 1
  78.     B$ = fBIN$( B?, 1 )
  79.     B? = fBINvalB?( B$ )
  80.     PRINT USING sMask$; B?; : PRINT B$
  81.   LOCATE 20, 1
  82.     PRINT USING sMask$; B?;
  83.     PRINT LEFT$( BIN$( B? ) + SPACE$(32), 32 )
  84.  
  85. END SUB
  86.  
  87. SUB DisplayI( BYVAL I% ) LOCAL PUBLIC
  88.   LOCAL I$
  89.  
  90.   LOCATE 17, 1
  91.     I$ = fBIN$( I%, 2 )
  92.     I% = fBINvalI%( I$ )
  93.     PRINT USING sMask$; I%; : PRINT I$
  94.   LOCATE 21, 1
  95.     PRINT USING sMask$; I%;
  96.     PRINT LEFT$( BIN$( I% ) + SPACE$(32), 32 )
  97.  
  98. END SUB
  99.  
  100. SUB DisplayL( BYVAL L& ) LOCAL PUBLIC
  101.   LOCAL L$
  102.  
  103.   LOCATE 18, 1
  104.     L$ = fBIN$( L&, 4 )
  105.     L& = fBINvalL&( L$ )
  106.     PRINT USING sMask$; L&; : PRINT L$
  107.   LOCATE 22, 1
  108.     PRINT USING sMask$; L&;
  109.     PRINT LEFT$( BIN$( L& ) + SPACE$(32), 32 )
  110.  
  111. END SUB
  112.  
  113.